package xyz.xtt.asset.enums;

import java.util.Arrays;
import java.util.Objects;

import org.apache.commons.lang3.StringUtils;

/**
 * 交易类型
 * 
 * @author huqibo
 * @date 2025/03/03
 */
public enum TransferActionEnum {

	/**
	 * 新注册
	 */
	CONFIRM(0, "确认"),
	/**
	 * 老用户
	 */
	CANCEL(1, "取消"),;

	private int code;
	private String desc;

	TransferActionEnum(int code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public int getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}

	public static boolean checkType(String checkType) {
		return Arrays.asList(TransferActionEnum.values()).stream().anyMatch(x -> Objects.equals(x.name(), checkType));
	}

	public static TransferActionEnum convert(String checkType) {
		return Arrays
				.asList(TransferActionEnum.values())
				.stream()
				.filter(x -> Objects.equals(x.name(), StringUtils.upperCase(StringUtils.trim(checkType))))
				.findFirst()
				.orElse(null);
	}
}
